﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HAILN_Y2016CS32ONLINE.Structure_Program.Exer
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void btnTinh_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtA.Text)) errorProvider1.SetError(txtA, "");
            else if (string.IsNullOrEmpty(txtB.Text)) errorProvider1.SetError(txtB, "");
            else if (string.IsNullOrEmpty(cbopheptinh.Text)) errorProvider1.SetError(cbopheptinh, "");
            else
            {
                double a = 0;
                double b = 0;
                if (!double.TryParse(txtA.Text, out a))
                { errorProvider1.SetError(txtA, "loi roi");
                txtA.Focus();
                }
                else if (!double.TryParse(txtB.Text, out b))
                {
                    errorProvider1.SetError(txtB, "loi roi");
                    txtA.Focus();
                }
                //Kiem tra su lua chon cua nguoi dung
                if (cbopheptinh.Text.Equals("Cộng")) 
                { 

                    // txtKetqua.Text = Convert.ToInt32(txtA.Text + txtB.Text).ToString();
                   // txtKetqua.Text = "" + (int.Parse(txtA.Text) + int.Parse(txtB.Text));
                    txtKetqua.Text ="" +(a + b);
                }
            
            
            }
            
        }
    }
}
